package ApptUtil;

import CreatorUtil.*;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import LoginUtil.UserBean;
import LoginUtil.UserDAO;

/**
 * Servlet implementation class RequestApptServlet
 */
public class RequestApptServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;


	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		Appointment appt = new Appointment(request.getParameter("datetime"), request.getParameter("reasonbox"), request.getParameter("doctordrop"));
		HttpSession session = request.getSession();
		if(UserDAO.insertAppt(appt, (Patient) (session.getAttribute("currentSessionUser"))))
		{
			response.sendRedirect("apptSuccess.jsp");
		}
	}

}
